import java.io.*;
import java.util.*;

public class Main {
	BufferedReader bf;
	StringTokenizer st;
	StringBuilder sb = new StringBuilder();
	
	int n, s;

	public static void main(String[] args) {		
		Main main = new Main();
		main.beginProcess();
	}

	public void beginProcess() {
		bf = new BufferedReader(new InputStreamReader(System.in));
		int t = 0;		
		
		try {
			st = new StringTokenizer(bf.readLine());
			t = Integer.parseInt(st.nextToken());
			
			while(t > 0) {
				st = new StringTokenizer(bf.readLine());
				n = Integer.parseInt(st.nextToken());
				s = Integer.parseInt(st.nextToken());
				
				getResult();
				
				t--;
			}

			System.out.print(sb);
		}
		catch(Exception ex) {
			System.err.println(ex.toString());
		}
	}
	
	private void getResult() {
		int defR, defC;
		int i, j;
		switch(s) {
			case 1:
				defR = 0;
				defC = n - 1;
				for(i = 0; i < n; i++) {
					for(j = 0; j < n; j++) {
						if(i == defR && j == defC) {
							if(j != n - 1) {
								sb.append("* ");
							} else {
								sb.append("*");
							}
						} else {
							if(j != n - 1) {
								sb.append("x ");
							} else {
								sb.append("x");
							}
						}
					}
					defR++;
					defC--;
					sb.append("\n");
				}
				break;
			case 2:
				defR = 0;
				defC = 0;
				for(i = 0; i < n; i++) {
					for(j = 0; j < n; j++) {
						if(i == defR && j == defC) {
							if(j != n - 1) {
								sb.append("* ");
							} else {
								sb.append("*");
							}
						} else {
							if(j != n - 1) {
								sb.append("x ");
							} else {
								sb.append("x");
							}
						}
					}
					defR++;
					defC++;
					sb.append("\n");
				}
				break;
			case 3:
				defC = n - 1;
				for(i = 0; i < n; i++) {
					for(j = 0; j < n; j++) {
						if(j == defC) {
							if(j != n - 1) {
								sb.append("* ");
							} else {
								sb.append("*");
							}
						} else {
							if(j != n - 1) {
								sb.append("x ");
							} else {
								sb.append("x");
							}
						}
					}
					sb.append("\n");
				}
				break;
			case 4:
				defC = 0;
				for(i = 0; i < n; i++) {
					for(j = 0; j < n; j++) {
						if(j == defC) {
							if(j != n - 1) {
								sb.append("* ");
							} else {
								sb.append("*");
							}
						} else {
							if(j != n - 1) {
								sb.append("x ");
							} else {
								sb.append("x");
							}
						}
					}
					sb.append("\n");
				}
				break;
		}
	}
	
}